<?php
$users = simplexml_load_file('data/user.xml');

if (isset($_POST["create"])){
  $user = $users->addChild("user");
  $user->addChild("username", $_POST["username"]);
  $user->addChild("password", md5($_POST["password"]));
  $pref = $user->addChild("preferences");
  $pref->addChild("class", "FRSOJRSR");
  $pref->addChild("alpha", "AZ");
  
  $dom = new DOMDocument('1.0');
  $dom->preserveWhiteSpace = false;
  $dom->formatOutput = true;
  $dom->loadXML($users->asXML(), LIBXML_NOBLANKS);
  $dom->save("data/user.xml");
}
?>
